﻿using CCS.BLL;
using CCS.BLL.Impl;
using System.Linq;
using CIK.Framework.Diagnostics;

namespace CCS.WebApp.ViewModels.HomePage.Builders.Impl
{
    public class HomePageVmBuilder : IHomePageVmBuilder
    {
        private readonly ICategoryManager _categoryManager;

        public HomePageVmBuilder()
            : this(new CategoryManager())
        {
        }

        public HomePageVmBuilder(ICategoryManager categoryManager)
        {
            _categoryManager = categoryManager;
        }

        public HomePageViewModel HomePageVmBuild()
        {
            Throw.IfArgumentNull(_categoryManager, "CategoryManager");

            var vm = new HomePageViewModel();

            vm.Categories = _categoryManager.GetAll().ToList();

            return vm;
        }
    }
}